package com.example.dllo.keepdemo.main;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.dllo.keepdemo.R;

import java.util.ArrayList;

/**
 * Created by dllo on 16/1/11.
 */
public class MyViewPagerAdapter extends FragmentPagerAdapter {
    private ArrayList<Fragment> data;
    private Context context;
    private String[] titles = {"训练","动态","我"};
    private int[] imageview = {R.drawable.selector_train,R.drawable.selector_dynamic,R.drawable.selector_me};

    public MyViewPagerAdapter(FragmentManager fm,ArrayList<Fragment> data,Context context) {
        super(fm);
        this.data = data;
        this.context = context;
    }

    @Override
    public Fragment getItem(int position) {
        return data.get(position);
    }

    @Override
    public int getCount() {
        return data.size();
    }

    public View getTabView(int position) {
        View view = LayoutInflater.from(context).inflate(R.layout.imageview_tablayout,null);
        ImageView image = (ImageView) view.findViewById(R.id.img_tablayout);
        TextView textView = (TextView) view.findViewById(R.id.tv_tablayout);
        textView.setText(titles[position]);
        image.setImageResource(imageview[position]);
        return view;
    }


}
